package org.mysfit.ctp4j.api.controller.v1;

import java.util.List;

import org.mysfit.ctp4j.api.vo.DemoVO;
import org.mysfit.ctp4j.core.service.DemoService;
import org.mysfit.ctp4j.infra.pojo.ApiResponse;
import org.mysfit.ctp4j.infra.pojo.CtpConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author long.gf
 * @since 2022-11-18
 */
@RestController
@RequestMapping("/v1/demo")
public class DemoController {
	
	@Autowired
	private CtpConfig ctpConfig;
	@Autowired
	private DemoService service;

	@GetMapping("/getConfig")
	public ApiResponse<CtpConfig> getConfig() {
		return ApiResponse.ok(ctpConfig);
	}
	
	@GetMapping("/list")
	public ApiResponse<List<DemoVO>> list() {
		List<DemoVO> result = service.listAll();
		return ApiResponse.ok(result);
	}
}
